package CtrLayer;
import java.util.Iterator;
import ModelLayer.Customer;
import ModelLayer.CustomerList;

public class CustomerCtr
{
    private static CustomerList instance = CustomerList.getInstance();

    public CustomerCtr()
    {

    }

    public void createCustomer(int id, String name, String address, String postCode, String phone, String email, String cvr, String type)
    {
        Customer newCustomer = new Customer(id, name, address, postCode, phone, email, cvr, type);
        instance.addCustomer(newCustomer);
    }

    public Customer getCustomer(int id) 
    {
        return instance.getCustomer(id);
    }
    
    public Iterator getCustomersIterator()
    {
        return instance.getCustomersIterator();
    }

    public boolean updateCustomer(int id, String updateValue, int opt)
    {
        Customer cust = getCustomer(id);
        try{
            switch(opt)
            {
                case 1 : { cust.setName(updateValue); } break;
                case 2 : { cust.setAddress(updateValue); } break;
                case 3 : { cust.setPostCode(updateValue); } break;
                case 4 : { cust.setPhone(updateValue); } break;
                case 5 : { cust.setEmail(updateValue); } break;
                case 6 : { cust.setCvr(updateValue); } break;
                case 7 : { cust.setType(updateValue); } break;
            }
            return true;
        }
        catch(Exception e) {}
        return false;
    }

    public boolean deleteCustomer(int id)
    {
        return instance.deleteCustomer(id);
    }
}
